package com.sooncode.project.focusservice._.request;

import com.sooncode.project.focusservice._.exceptions.RequestHttpErrorException;
import com.sooncode.project.springcloudcommon.config.MyFeignConfig;
import feign.hystrix.FallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

@FeignClient(value = "psychology-service",fallbackFactory = OrgSyncClient.orgSyncClientFallback.class,configuration = MyFeignConfig.class)
public interface OrgSyncClient {
    @PostMapping(value = "/organization/syncCreateOrg")
    String syncCreateOrg(@RequestParam Map<String, Object> map);
    public class orgSyncClientFallback implements FallbackFactory<OrgSyncClient> {
        @Override
        public OrgSyncClient create(Throwable throwable) {
            throwable.printStackTrace();
            throw new RequestHttpErrorException(throwable.getMessage());
        }
    }
}
